<?php $this->load->view('header');?>

<body class="childrenBody custom_body">
	<div class="custom_main">
		<fieldset class="layui-elem-field layui-field-title">
		  <legend>公告信息</legend>
		</fieldset>

		<form class="layui-form">
			<div class="layui-form-item">
				<label class="layui-form-label custom_i"><i>*</i> 公告标题：</label>
				<div class="layui-input-inline">
					<input type="text" name="notice_title" required lay-verify="required" placeholder="请输入标题" autocomplete="off" class="layui-input" value="">
				</div> 
			</div>
			
			<div class="layui-form-item">
				<label class="layui-form-label">公告详情：</label>
			    <div class="layui-input-block">
			      <textarea placeholder="请输入简介" id="LAY_demo1" class="layui-textarea" style="display: none"></textarea>
			    </div>
			</div>

			<div class="layui-form-item">
				<div class="layui-input-block">
					<button class="layui-btn layui-btn-normal" lay-submit="" lay-filter="addUser">立即发布</button>
			    </div>
			</div>
		</form>
		
	</div>

	<script type="text/javascript">
		layui.config({
			version: true
		}).use(['jquery','layer', 'form', 'laytpl', 'upload', 'layedit'],function(){
			var form = layui.form,
				layer = parent.layer === undefined ? layui.layer : parent.layer,
				laypage = layui.laypage,
				laytpl = layui.laytpl,
				upload = layui.upload,
				layedit = layui.layedit,
				$ = layui.jquery;

				//构建一个默认的编辑器
				 var index = layedit.build('LAY_demo1', {
					  tool: ['strong', 'italic', 'underline', '|', 'del', 'left', 'center', 'right']
				  });

				//提交表单
				form.on("submit(addUser)",function(data)
				{
					data.field['content'] = layedit.getContent(index); //详情简介

					$.post('admin.php/Home/insert_notice', data.field, function(result) {
						if (result.status == 200) 
						{
							layer.msg(result.message, {icon: 1});
							location.reload();
						}
						else
						{
							layer.msg(result.message, {icon: 5});
						}

					},"json");

					return false;
				});

				form.render(); //更新全部

		});

	</script>

</body>
</html>